﻿package DevilCat{
	public class PokemonMove {
		public var Name:String;
		public var Type:String;
		public var Attack:Number;
		public var Accuracy:Number;
		public var Category:String;
		public var Critical:Number;
		public var MaxAttack:Number;
		public var MaxAccuracy:Number;
		public var MaxCritical:Number;
		public var PP:Number;
		//public var EType:String;
		//public var EStat:String;
		//public var Effect:Number;
		//public var EAcc:Number;
		public var Effect:XMLList;

		public function PokemonMove(SQLData:XMLList) {
			Name=SQLData.name();
			Type=SQLData.Type;
			MaxAttack=Number(SQLData.Atk);
			MaxAccuracy=Number(SQLData.Acc);
			if (String(SQLData.C)!="") {
				MaxCritical=8;
			} else {
				MaxCritical=16;
			}
			setDefaultValue();
			//Attack=MaxAttack;
			//Accuracy=MaxAccuracy;
			PP=(45-Number(SQLData.PP))*1;
			Category=SQLData.Cat;
			Effect=SQLData.Effect;
			//EType=SQLData.EType;
			//EStat=SQLData.EStat;
			//Effect=SQLData.Effect;
			//EAcc=SQLData.EAcc;
		}
		public function setDefaultValue(){
			Critical=MaxCritical
			Attack=MaxAttack;
			Accuracy=MaxAccuracy;			
		}
		public function isCritical():Boolean {
			if (Math.round(Math.random()*Critical)==1) {
				return true;
			} else {
				return false;
			}
		}
	}
}